<?php echo $this->Session->flash(); ?>

<script>
    $(document).ready(function(){

        $("input[type=checkbox]").click(
        function() {
            if($(this).attr('className')=='tipo3'){
                $("#calificacion").attr("value", 3);
                $(".tipo1").attr("checked",false);
                $(".tipo2").attr("checked",false);
            }else{
                if($(this).attr('className')=='tipo2'){
                    $("#calificacion").attr("value", 2);
                    $(".tipo1").attr("checked",false);
                    $(".tipo3").attr("checked",false);
                }else
                    if($(this).attr('className')=='tipo1'){
                        $("#calificacion").attr("value", 1);
                        $(".tipo2").attr("checked",false);
                        $(".tipo3").attr("checked",false);
                    }
            }
        }
    )

    });
    function setcheck(){
    }
</script>

<h1><?php echo "Predio:  " . $this->data['Property']['nombre'] . "  " . $this->data['Property']['codigo'] ?></h1>
<br>
<h1><?php echo $this->data['Requirement']['texto'] ?></h1>


<?php
echo $form->create('PropertyRequirement');
echo $form->input("PropertyRequirement.id");
echo $form->hidden("PropertyRequirement.property_id");
?>
<table border="1" width="100%" >
    <tbody>
        <?php
        foreach ($condiciones as $con):
            $ch = "";

            foreach ($chequeados as $val) {
                if ($con['RequirementFault']['id'] == $val['PropertyRequirementsRequirementFault']['requirement_fault_id']) {
                    $ch = "checked";
                }
            }
            ?>
            <tr>
                <td width="20%"><?php echo $form->input("RequirementFault.id", array('type' => 'checkbox', 'label' => '', 'class' => 'tipo' . $con['RequirementFault']['tipo'], 'value' => $con['RequirementFault']['id'], 'name' => 'checked[]', 'checked' => $ch)); ?></td>
                <td width="80%" style="text-align: justify"><label><?php echo $con['RequirementFault']['nombre'] ?></label></td>
            </tr>
        <?php endforeach; ?>
    </tbody>
</table>
<?php
echo $form->input("PropertyRequirement.concepto", array('label' => 'Observaciones', 'class' => 'txtarea'));
echo $form->hidden("PropertyRequirement.calificacion", array('id' => 'calificacion'));
?>
<div id="loading" style="display: none;">
    <?php echo $html->image('loading.gif', array('border' => "0", 'align' => 'center')); ?>
</div>
<?php
if ($est == 0)
    if ($this->Session->read('estado') == 0)
        echo $ajax->submit('Guardar', array('url' => array('controller' => 'PropertyRequirements', 'action' => 'edit'), 'update' => 'content', 'complete' => 'cargar()', 'indicator' => 'loading'));
echo $form->end();
echo $ajax->link("REGRESAR", array('controller' => 'PropertyRequirements', "action" => "index", $this->data['PropertyRequirement']['property_id']), array('update' => 'content', 'complete' => 'cargar()'))
?>
